package com.hqd.ch03.v11.spel.standard;

/**
 *
 */
public class Token {
    private int endPos;
    private int startPos;
    private String data;
    private TokenKind kind;

    public Token(TokenKind tokenKind, int startPos, int endPos) {
        this.kind = tokenKind;
        this.startPos = startPos;
        this.endPos = endPos;
    }

    public Token(TokenKind tokenKind, char[] tokenData, int startPos, int endPos) {
        this(tokenKind, startPos, endPos);
        this.data = new String(tokenData);
    }

    public boolean isIdentifier() {
        return (this.kind == TokenKind.IDENTIFIER);
    }

    public TokenKind getKind() {
        return kind;
    }

    public int getEndPos() {
        return endPos;
    }

    public int getStartPos() {
        return startPos;
    }

    public boolean isNumericRelationalOperator() {
        return (this.kind == TokenKind.GT || this.kind == TokenKind.GE || this.kind == TokenKind.LT ||
                this.kind == TokenKind.LE || this.kind == TokenKind.EQ || this.kind == TokenKind.NE);
    }

    public String getData() {
        return data;
    }
}
